From d319e5e5797f0820a881bbcb5352520394888bed Mon Sep 17 00:00:00 2001 From: robertlipe Date: Sun, 15 Sep 2013 07:18:39 +0000 Subject: [PATCH] Replace guts of manual trimmed_strdup in tef reader. Reduce type thrash. --- gpsbabel/tef_xml.cc | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/gpsbabel/tef_xml.cc b/gpsbabel/tef_xml.cc index f03082a99..44d0a8a59 100644 --- a/gpsbabel/tef_xml.cc +++ b/gpsbabel/tef_xml.cc @@ -47,19 +47,10 @@ static arglist_t tef_xml_args[] = { #define MYNAME "TourExchangeFormat" static char* -trimmed_strdup(const char* str) +trimmed_strdup(const QString& str) { - char* c1, *c2, *res; - - c1 = xstrdup(str); - c2 = lrtrim(c1); - if (*c2) { - res = xstrdup(c2); - } else { - res = NULL; - } - xfree(c1); - return res; + QString trimmed = str.trimmed(); + return xstrdup(CSTR(trimmed)); } static xg_callback tef_start, tef_header, tef_list_start, tef_list_end; @@ -112,9 +103,9 @@ tef_header(const char* args, const QXmlStreamAttributes* attrv) route = route_head_alloc(); foreach(QXmlStreamAttribute attr, *attrv) { if (attr.name().compare("Name", Qt::CaseInsensitive) == 0) { - route->rte_name = trimmed_strdup(attr.value().toString().toUtf8().constData()); + route->rte_name = trimmed_strdup(attr.value().toString()); } else if (attr.name().compare("Software", Qt::CaseInsensitive) == 0) { - route->rte_desc = trimmed_strdup(attr.value().toString().toUtf8().constData()); + route->rte_desc = trimmed_strdup(attr.value().toString()); } } route_add_head(route); -- 2.30.2